package com.assess.web.service.impl;

import com.assess.web.dao.CompanyMapper;
import com.assess.web.model.Company;
import com.assess.web.model.CompanyExample;
import com.assess.web.service.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CompanyServiceImpl implements CompanyService {

    @Autowired
    private CompanyMapper companyMapper;

    @Override
    public List<Company> listCompany() {
        return companyMapper.selectByExample(new CompanyExample());
    }

    @Override
    public Company getCompany(int companyId) {
        return companyMapper.selectByPrimaryKey(companyId);
    }

    @Override
    public int saveCompany(String name) {
        Company company = new Company();
        company.setName(name);
        return companyMapper.insertSelective(company);
    }
}
